using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;

namespace GMME
{
    [DataContract]
    public class Axis
    {
        // 在世界坐标系前轴的单位向量, 该参数是长度为 3 的数组，三个值依次表示前、右、上的坐标值
        [DataMember(Name = "forward")]
        public float[] Forward
        {
            get;
            set;
        }

        // 在世界坐标系右轴的单位向量, 该参数是长度为 3 的数组，三个值依次表示前、右、上的坐标值
        [DataMember(Name = "right")]
        public float[] Right
        {
            get;
            set;
        }

        // 在世界坐标系上轴的单位向量, 该参数是长度为 3 的数组，三个值依次表示前、右、上的坐标值
        [DataMember(Name = "up")]
        public float[] Up
        {
            get;
            set;
        }

#if UNITY_ANDROID
        internal static Axis ConvertAxis(AndroidJavaObject javaObject)
        {
            Axis axis = new Axis();
            if (javaObject != null)
            {
                float[] forward = javaObject.Call<float[]>("getForward");
                axis.Forward = forward;
                float[] right = javaObject.Call<float[]>("getRight");
                axis.Right = right;
                float[] up = javaObject.Call<float[]>("getUp");
                axis.Up = up;
                Debug.LogFormat("Forward={0}, Right={1}, Up={2}",axis.Forward, axis.Right, axis.Up);
            }
            return axis;
        }
#endif

    }
}